package cn.iocoder.yudao.framework.common.genId;

public class PKGenerator {
    private static PKGenerator instance = null;
    private TwitterIDBuilder idBuilder = null;

    private PKGenerator() {
        this.idBuilder = new TwitterIDBuilder(0, 0);
    }

    public static PKGenerator getInstance() {
        return instance;
    }

    public void init(int datacenter_id, int worker_id) {
        this.idBuilder = new TwitterIDBuilder(datacenter_id, worker_id);
    }

    public String newKey() {
        return this.idBuilder.newNextId();
    }

    public static String newId() {
        return getInstance().newKey();
    }


    static {
        instance = new PKGenerator();
    }
}
